/**
 * @author ntran
 */
package  {
	import org.flixel.*;
	
	public class Player extends FlxSprite {
		[Embed (source="data/Player05.png")] public var sprite:Class;
		
		private var moving:Boolean;
		
		public function Player(X:int, Y:int) {
			super(X, Y);
			loadGraphic(sprite, true,false, 32,32);
			
			moving = false;
			
			this.addAnimation("idle", [0]);
			this.addAnimation("walk", [0,1,2,3], 10, true);
		}
		
		override public function update():void
		{
			super.update();
			
			if(FlxG.keys.RIGHT)
			{
				velocity.x = 100;
			}
			else if(FlxG.keys.LEFT)
			{
				velocity.x = -100;
			}
			else
			{
				velocity.x = 0;
			}
			
			if(FlxG.keys.UP)
			{
				velocity.y = -100;
			}
			else if(FlxG.keys.DOWN)
			{
				velocity.y = 100;
			}
			else
			{
				velocity.y = 0;
			}
			
			if(velocity.x ==0 && velocity.y == 0)
				this.play("idle");
			else
				this.play("walk");
		}
	}
}